<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">


    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

      </a-table>
    </div>

  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'



  export default {
    name: "TaskList",
    mixins:[JeecgListMixin],
    components: {  },
    props:{
      mainId:{
        type:String,
        default:'',
        required:false
      }
    },
    watch:{
      mainId:{
        immediate: true,
        handler(val) {
          if(!this.mainId){
            this.clearList()
          }else{
            this.queryParam['framId'] = val
            this.loadData(1);
          }
        }
      }
    },
    data () {
      return {
        description: 'frame_copy1管理页面',
        disableMixinCreated:true,
        // 表头
        columns: [
          {
            title:'加工顺序',
            align:"center",
            dataIndex: 'handleSort'
          },
          {
            title:'任务单号',
            align:"center",
            dataIndex: 'taskNo'
          },
          {
            title:'工序编号',
            align:"center",
            dataIndex: 'procCode'
          },
          {
            title:'工序名称',
            align:"center",
            dataIndex: 'procName'
          },
          {
            title:'任务数量',
            align:"center",
            dataIndex: 'taskCount'
          },
          {
            title:'在制数量',
            align:"center",
            dataIndex: 'inProcCount'
          },
          {
            title:'报工数量',
            align:"center",
            dataIndex: 'reportCount'
          },
          {
            title:'合格数量',
            align:"center",
            dataIndex: 'eligibilityCount'
          }
        ],
        url: {
          list: "/engine/engineering/listTaskByMainId",
          exportXlsUrl: "/task/frameCopy1/exportTask",
          importUrl: "/task/frameCopy1/importTask",
        },
        dictOptions:{
        },

      }
    },
    computed: {
      importExcelUrl(){
        return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`;
      }
    },
    methods: {
      clearList(){
        this.dataSource=[]
        this.selectedRowKeys=[]
        this.ipagination.current = 1
      },

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>
